﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace AssemblyLoader
{
    [Serializable]
    public class TypePropertyInfo
    {
        public string Name { get; set; }
        public TypeInfo PropertyType { get; set; }

        public TypePropertyInfo(PropertyInfo prop_info)
        {
            Name = prop_info.Name;
            //PropertyType = new TypeInfo(prop_info.PropertyType);
        }

        public override string ToString()
        {
            return Name;
        }
    }

    [Serializable]
    public class TypeInfo
    {
        public string Name { get; set; }
        public string AssemblyName { get; set; }
        public List<TypePropertyInfo> Properties { get; set; }

        public TypeInfo(Type reflected_type)
        {
            Name = reflected_type.FullName;
            AssemblyName = reflected_type.Assembly.GetName().Name;
            PropertyInfo[] obj_props = reflected_type.GetProperties();
            Properties = new List<TypePropertyInfo>();
            foreach (var prop in obj_props)
            {
                Properties.Add(new TypePropertyInfo( prop));
            }
        }
    }
}
